package com.itHsuSE.demo9;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author Hsu琛君珩
 * @ClassName:Test4
 * @date 2023-12-20
 * @apiNote
 * @Version: v1.0
 */

public class Test4 {
    public static void main(String[] args) throws IOException {
        byte[] bytes=new byte[1024];

        File file=new File("test3.txt");
        InputStream in=new FileInputStream(file);
        int n=in.read(bytes,0,1024);
        in.close();

        System.out.println("成功:n="+n+"个字节");

        String str=new String(bytes,0,1024,"UTF8");
        System.out.println("读取结果："+str);
    }
}
